/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.lodz.p.ftims.ProjektZespolowy2.entities;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Łukasz Gadomski
 */
@Entity
@Table(name = "working_cards")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "WorkingCard.findAll", query = "SELECT w FROM WorkingCard w"),
    @NamedQuery(name = "WorkingCard.findByWrkCardId", query = "SELECT w FROM WorkingCard w WHERE w.wrkCardId = :wrkCardId"),
    @NamedQuery(name = "WorkingCard.findBySalary", query = "SELECT w FROM WorkingCard w WHERE w.salary = :salary"),
    @NamedQuery(name = "WorkingCard.findByPosition", query = "SELECT w FROM WorkingCard w WHERE w.position = :position"),
    @NamedQuery(name = "WorkingCard.findByStartJob", query = "SELECT w FROM WorkingCard w WHERE w.startJob = :startJob"),
    @NamedQuery(name = "WorkingCard.findByActive", query = "SELECT w FROM WorkingCard w WHERE w.active = :active")})
public class WorkingCard implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "wrk_card_id")
    private Integer wrkCardId;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "salary")
    private Float salary;
    @Size(max = 20)
    @Column(name = "position")
    private String position;
    @Column(name = "start_job")
    @Temporal(TemporalType.TIMESTAMP)
    private Date startJob;
    @Basic(optional = false)
    @NotNull
    @Column(name = "active")
    private boolean active;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "wrkCardId")
    private Collection<WorkingDay> workingDaysCollection;
    @JoinColumn(name = "ward_id", referencedColumnName = "ward_id")
    @ManyToOne(optional = false)
    private Ward wardId;
    @JoinColumn(name = "doctor_id", referencedColumnName = "user_id")
    @ManyToOne(optional = false)
    private User doctorId;

    public WorkingCard() {
    }

    public WorkingCard(Integer wrkCardId) {
        this.wrkCardId = wrkCardId;
    }

    public WorkingCard(Integer wrkCardId, boolean active) {
        this.wrkCardId = wrkCardId;
        this.active = active;
    }

    public Integer getWrkCardId() {
        return wrkCardId;
    }

    public void setWrkCardId(Integer wrkCardId) {
        this.wrkCardId = wrkCardId;
    }

    public Float getSalary() {
        return salary;
    }

    public void setSalary(Float salary) {
        this.salary = salary;
    }

    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    public Date getStartJob() {
        return startJob;
    }

    public void setStartJob(Date startJob) {
        this.startJob = startJob;
    }

    public boolean getActive() {
        return active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    @XmlTransient
    public Collection<WorkingDay> getWorkingDaysCollection() {
        return workingDaysCollection;
    }

    public void setWorkingDaysCollection(Collection<WorkingDay> workingDaysCollection) {
        this.workingDaysCollection = workingDaysCollection;
    }

    public Ward getWardId() {
        return wardId;
    }

    public void setWardId(Ward wardId) {
        this.wardId = wardId;
    }

    public User getDoctorId() {
        return doctorId;
    }

    public void setDoctorId(User doctorId) {
        this.doctorId = doctorId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (wrkCardId != null ? wrkCardId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof WorkingCard)) {
            return false;
        }
        WorkingCard other = (WorkingCard) object;
        if ((this.wrkCardId == null && other.wrkCardId != null) || (this.wrkCardId != null && !this.wrkCardId.equals(other.wrkCardId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pl.lodz.p.ftims.ProjektZespolowy2.entities.WorkingCards[ wrkCardId=" + wrkCardId + " ]";
    }
    
}
